package com.qth.valet.mapper.provider;

import org.apache.ibatis.jdbc.SQL;

public class OrderProvider {

    public String selectOrderByStatus(Integer driverId, Integer status) {
        return new SQL() {{
            SELECT("o.*," +
                            "u.username," +
                            "u.avatar");
            FROM("orders o");
            LEFT_OUTER_JOIN("users u on u.id = o.user_id");
            WHERE("driver_id = " + driverId);
            // 动态添加条件
            if (status != null) {
                WHERE("o.status = " + status);
            }
            ORDER_BY("o.status, o.id desc");
        }}.toString();
    }

  /*  public static void main(String[] args) {
        System.out.println(new OrderProvider().selectOrderByStatus(21, 5));
    }*/

}
